<template>
  <j-modal
    title="详情"
    :width="modalWidth"
    :footer="null"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @cancel="handleCancel"
    @ok="handleCancel"
    @update:fullscreen="isFullscreen"
    wrapClassName="j-depart-select-modal"
    switchFullscreen
    cancelText="关闭">
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :pagination="false"
        :columns="columns"
        :dataSource="dataSource"
        :loading="loading"
        class="j-table-force-nowrap">
      </a-table>
  </j-modal>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'

  export default {
    name: 'VcaFamilyDetail',
    components: {
    },
    props: {
      modalWidth:{
        type:Number,
        default:800,
        required:false
      }
    },
    data () {
      return {
        loading:true,
        visible:false,
        confirmLoading:false,
        fullscreen:false,
        dataSource:[],
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'姓名',
            align:"center",
            dataIndex: 'residentName'
          },
          {
            title:'身份证',
            align:"center",
            dataIndex: 'idcard'
          },
          {
            title:'手机号',
            align:"center",
            dataIndex: 'mobile'
          },
          {
            title:'关系',
            align:"center",
            dataIndex: 'familyRelation'
          }
        ],
        url: "/villageCadreAssist/vcaResident/list",
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
    },
    methods: {
      edit (record) {
        //this.model = Object.assign({}, record);
        this.visible = true;
        this.loadData(record["familyCode"]);
      },
      handleCancel(){
        this.handleClear()
      },
      handleClear(){
        this.visible=false
        this.checkedKeys=[]
      },
      loadData(familyCode) {
        this.loading = true;
        getAction(this.url, {familyCode:familyCode }).then((res) => {
          if (res.success) {
            this.dataSource = res.result.records||res.result;
          }else{
            this.$message.warning(res.message)
          }
        }).finally(() => {
          this.loading = false
        })
      },
      isFullscreen(val){
        this.fullscreen=val
      }
    }
  }
</script>